<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="../css/mui.min.css">
		<style>
			.mui-bar {
				background-color: #313131;
			}
			
			.mui-bar h1 {
				color: #FFFFFF;
			}
			
			.mui-bar a {
				color: #FFFFFF;
			}
		</style>
		<style>
			.mui-plus .plus {
				display: inline;
			}
			
			.plus {
				display: none;
			}
			
			#topPopover {
				position: fixed;
				top: 16px;
				right: 6px;
			}
			
			#topPopover .mui-popover-arrow {
				left: auto;
				right: 6px;
			}
			
			p {
				text-indent: 22px;
			}
			
			span.mui-icon {
				font-size: 14px;
				color: #007aff;
				margin-left: -15px;
				padding-right: 10px;
			}
			
			.mui-content {}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">中诚黄金</h1>
			<a href="#bottomPopover" id="openPopover" class=" mui-icon mui-icon-right-nav mui-pull-right">

				<img id="imgShare" width="26px" height="26px" src="" </img>
			</a>
		</header>
		<div class="mui-content" style="">
			<iframe id="if_page" width="100%" src="sub.html" frameborder="no" border="0" marginwidth="0" marginheight="0" allowtransparency="yes">
				
			</iframe>
		</div>

		<script src="../js/mui.min.js"></script>
		<script type="text/javascript" src="../js/Common.js"></script>
		<script type="text/javascript">
			//启用双击监听
			mui.init({
				gestureConfig: {
					doubletap: true
				},
				/*subpages: [{
					url: getUrlParam('url'),
					id: getUrlParam('url'),
					styles: {
						top: '45px',
						bottom: '0px',
					}
				}]*/
			});

			var toGoUrl = getUrlParam('url');

			document.getElementById('if_page').style.height = (getWinHeight() - 45) + 'px';

			document.getElementById('if_page').src = toGoUrl;

			var contentWebview = null;
			mui.plusReady(function() {
				//初始化分享内容
				var shareInfo = plus.webview.currentWebview().shareInfo;
				setShareMsg(shareInfo.title, shareInfo.content);

				document.querySelector('header').addEventListener('doubletap', function() {
					if(contentWebview == null) {
						contentWebview = plus.webview.currentWebview().children()[0];
					}
					contentWebview.evalJS("mui('#pullrefresh').pullRefresh().scrollTo(0,0,100)");
				});
				document.getElementById('imgShare').addEventListener('tap', function() {
					openShare();
					//mui('#popover').popover('toggle');
				});

			});

			function share() {
				mui('#popover').popover('toggle'); //show hide toggle

			}
		</script>

		<script type="text/javascript">
			var msg = {
				"href": toGoUrl,
				"title": "中诚黄金",
				"content": "中诚黄金是上海黄金交易所的会员，专业从事黄金T+D业务的咨询服务，致力于为广大客户提供及时、全面、专业的黄金投资咨询服务。",
				"thumbs": ["_www/logo.png"]
			};

			function setShareMsg(title, zhaiyao) {
				msg.title =  title;
				msg.content =  zhaiyao;
			}

			function openShare() {
				shareWebview();
			}
			mui.plusReady(function() {
				ws = plus.webview.currentWebview();
				//关闭splash页面；
				plus.navigator.closeSplashscreen();
			})
			var sharew;
			var ws = null;
			/**
			 *分享窗口
			 */
			function shareWebview() {
				ws = plus.webview.currentWebview();
				if(sharew) { // 避免快速多次点击创建多个窗口
					return;
				}
				var top = plus.display.resolutionHeight - 134;
				var href = "share.html";
				sharew = plus.webview.create(href, "share.html", {
					width: '100%',
					height: '134',
					top: top,
					scrollIndicator: 'none',
					scalable: false,
					popGesture: 'none'
				}, {
					shareInfo: {
						"href": msg.href,
						"title": msg.title,
						"content": msg.content,
						"logo": msg.thumbs,
						"pageSourceId": ws.id
					}
				});
				sharew.addEventListener("loaded", function() {
					sharew.show('slide-in-bottom', 300);
				}, false);
				// 显示遮罩层  
				ws.setStyle({
					mask: "rgba(0,0,0,0.5)"
				});
				// 点击关闭遮罩层
				ws.addEventListener("maskClick", closeMask, false);
			}

			function closeMask() {
				ws.setStyle({
					mask: "none"
				});
				//避免出现特殊情况，确保分享页面在初始化时关闭 
				if(!sharew) {
					sharew = plus.webview.getWebviewById("share.html");
				}
				if(sharew) {
					sharew.close();
					sharew = null;
				}
			}
		</script>
	</body>

</html>